package com.bes.aiProject.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bes.aiProject.entry.SxMBusinessProcessConf;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface SxMBusinessProcessConfMapper extends BaseMapper<SxMBusinessProcessConf> {

    @Select("<script>\n" +
            "select t1.*,t2.metric_code ,t2.metric_name ,t2.abnormal_type ,t2.metric_weight from sx_m_business_process_conf t1 inner join sx_m_metric_conf t2 on #{leafCode}=leaf_code \n" +
            "where 1=1\n" +
            "<if test=“enterpriseCode != null and enterpriseCode != ‘’”>\n" +
            "and enterprise_code = #{enterpriseCode}\n" +
            "</if> \n" +
            "<if test=“businessCode != null and businessCode != ‘’”>\n" +
            "and business_code = #{businessCode}\n" +
            "</if> \n" +
            "<if test=“taskCode != null and taskCode != ‘’”>\n" +
            "and task_code = #{taskCode}\n" +
            "</if> \n" +
            "</script>")
    List<SxMBusinessProcessConf> getLeafMetricList(@Param("leafCode") String leafCode, @Param("enterpriseCode") String enterpriseCode, @Param("businessCode") String businessCode, @Param("taskCode") String taskCode);
}
